//
//  CarManageListCell.m
//  Cycling
//
//  Created by cjg.mini on 2023/3/13.
//

#import "CarManageListCell.h"

@implementation CarManageListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {
    self.carImView = [[UIImageView alloc] init];
    self.carImView.image = [UIImage imageNamed:@"icon_mine_carim"];
    [self.contentView addSubview:self.carImView];
    [self.carImView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.contentView).offset(MARGIN_MAX);
        make.size.mas_equalTo(CGSizeMake(32, 32));
    }];
    
    self.deleteBtn = [[UIButton alloc] init];
    [self.deleteBtn setTitle:@"解除绑定" forState:(UIControlStateNormal)];
    self.deleteBtn.titleLabel.font = FONT_BODY_16;
    self.deleteBtn.titleLabel.textColor = COLOR_TOPIC_SELECT;
    self.deleteBtn.layer.cornerRadius = DEFAULT_CORNER_RADIUS;
    self.deleteBtn.layer.masksToBounds = YES;
    self.deleteBtn.layer.borderWidth = 1;
    self.deleteBtn.layer.borderColor = COLOR_TOPIC_SELECT.CGColor;
    [self.contentView addSubview:self.deleteBtn];
    [self.deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-MARGIN_MAX);
        make.centerY.mas_equalTo(self.carImView.ce_centerY);
        make.size.mas_equalTo(CGSizeMake(98, 30));
    }];

    self.carNameLB = [[UILabel alloc] init];
    self.carNameLB.text = @"MY bike";
    self.carNameLB.font = FONT_PRIMARY_TITLE;
    self.carNameLB.textColor = COLOR_BLACK;
    [self.contentView addSubview:self.carNameLB];
    [self.carNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(30);
        make.centerY.mas_equalTo(self.carImView.ce_centerY);
        make.left.equalTo(self.carImView.mas_right).offset(MARGIN_MIDDLE);
        make.right.equalTo(self.deleteBtn.mas_left).offset(-MARGIN_MIDDLE);
    }];

    self.carNumTitleLB = [[UILabel alloc] init];
    self.carNumTitleLB.font = FONT_PRIMARY_TITLE;
    self.carNumTitleLB.text = @"车辆型号";
    self.carNumTitleLB.textColor = COLOR_NOT_SELECT;
    [self.contentView addSubview:self.carNumTitleLB];
    [self.carNumTitleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(self.contentView.bounds.size.width/3);
        make.left.equalTo(self.contentView).offset(MARGIN_MAX);
        make.bottom.equalTo(self.contentView).offset(-MARGIN_MAX);
    }];
    self.carNumLB = [[UILabel alloc] init];
    self.carNumLB.text = @"FZ9887898";
    self.carNumLB.font = FONT_BODY_15;
    self.carNumLB.textColor = COLOR_NOT_SELECT;
    [self.contentView addSubview:self.carNumLB];
    [self.carNumLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(self.contentView.bounds.size.width/3);
        make.bottom.equalTo(self.carNumTitleLB.mas_top).offset(0);
        make.left.equalTo(self.contentView).offset(MARGIN_MAX);
    }];
    
    self.carPowerTitleLB = [[UILabel alloc] init];
    self.carPowerTitleLB.text = @"电机功率";
    self.carPowerTitleLB.font = FONT_BODY_15;
    self.carPowerTitleLB.textColor = COLOR_NOT_SELECT;
    self.carPowerTitleLB.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.carPowerTitleLB];
    [self.carPowerTitleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(self.contentView.bounds.size.width/3);
        make.bottom.equalTo(self.contentView).offset(-MARGIN_MAX);
        make.left.equalTo(self.carNumTitleLB.mas_right).offset(0);
    }];
    self.carPowerLB = [[UILabel alloc] init];
    self.carPowerLB.text = @"123KW";
    self.carPowerLB.font = FONT_BODY_15;
    self.carPowerLB.textColor = COLOR_NOT_SELECT;
    self.carPowerLB.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:self.carPowerLB];
    [self.carPowerLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(self.contentView.bounds.size.width/3);
        make.bottom.equalTo(self.carPowerTitleLB.mas_top).offset(-MARGIN_MAX);
        make.left.equalTo(self.carNumLB.mas_right).offset(0);
    }];
    
    self.carTimeTitleLB = [[UILabel alloc] init];
    self.carTimeTitleLB.text = @"连接时间";
    self.carTimeTitleLB.font = FONT_BODY_15;
    self.carTimeTitleLB.textColor = COLOR_NOT_SELECT;
    self.carTimeTitleLB.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.carTimeTitleLB];
    [self.carTimeTitleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(self.contentView.bounds.size.width/3);
        make.bottom.right.equalTo(self.contentView).offset(-MARGIN_MAX);
    }];
    self.carTimeLB = [[UILabel alloc] init];
    self.carTimeLB.text = @"2023.03.05";
    self.carTimeLB.font = FONT_BODY_15;
    self.carTimeLB.textColor = COLOR_NOT_SELECT;
    self.carTimeLB.textAlignment = NSTextAlignmentRight;
    [self.contentView addSubview:self.carTimeLB];
    [self.carTimeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(20);
        make.width.mas_equalTo(self.contentView.bounds.size.width/3);
        make.right.equalTo(self.contentView).offset(-MARGIN_MAX);
        make.bottom.equalTo(self.carTimeTitleLB.mas_top).offset(0);
    }];

}


@end
